//
//  LookForGoodsTableViewCell.m
//  GLGW_Shoping
//
//  Created by yang on 2018/12/5.
//  Copyright © 2018年 yang. All rights reserved.
//

#import "LookForGoodsTableViewCell.h"

@interface LookForGoodsTableViewCell ()
@property (nonatomic,strong) GLGWImageView * leftImageView;
@property (nonatomic,strong) GLGWLabel * stellNameLabel;
@property (nonatomic,strong) GLGWLabel * specLabel;
@property (nonatomic,strong) GLGWLabel * inventoryLabel;
@property (nonatomic,strong) GLGWLabel * warehouseLabel;
@property (nonatomic,strong) GLGWLabel * piceLabel;

@property (nonatomic,strong) GLGWView * lineView;
@property (nonatomic,strong) GLGWLabel * contactLabel;
@end

@implementation LookForGoodsTableViewCell{
    GLGWButton * showConfBut;
    GLGWButton * contactBut;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        GLGWView * bankgroundView = [[GLGWView alloc] initWithInSuperView:self.contentView];
        bankgroundView.backgroundColor = [UIColor whiteColor];
        [bankgroundView setViewShadowWidth:3.0 theCornerRadius:3.0];
        [bankgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView.mas_left).offset(kWidthProportion_In_iPhoneTriploid(15));
            make.right.equalTo(self.contentView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(15));
            make.top.equalTo(self.contentView.mas_top).offset(kHeightProportion_In_iPhoneTriploid(10));
            make.bottom.equalTo(self.contentView.mas_bottom).offset(-kHeightProportion_In_iPhoneTriploid(10));
        }];
        //
        self.leftImageView = [[GLGWImageView alloc] initWithFrame:CGRectMake(kWidthProportion_In_iPhoneTriploid(15), kHeightProportion_In_iPhoneTriploid(13), kWidthProportion_In_iPhoneTriploid(90), kHeightProportion_In_iPhoneTriploid(90)) inSuperView:bankgroundView];
        self.leftImageView.backgroundColor = kRandomColor;
        //
        self.stellNameLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(16) theColor:kColor_Rule_Black inSuperView:bankgroundView];
        self.stellNameLabel.backgroundColor = kRandomColor;
        self.stellNameLabel.text = @"三级螺纹钢 HRB400E 河钢";
        [self.stellNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.leftImageView.mas_right).offset(kWidthProportion_In_iPhoneTriploid(15));
            make.top.equalTo(bankgroundView.mas_top).offset(kHeightProportion_In_iPhoneTriploid(13));
            make.right.equalTo(bankgroundView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(15));
        }];
        //
        self.specLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(16) theColor:[UIColor colorWithHexString:@"#666666"] inSuperView:bankgroundView];
        self.specLabel.backgroundColor = kRandomColor;
        self.specLabel.text = @"φ6*12";
        [self.specLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.stellNameLabel);
            make.top.equalTo(self.stellNameLabel.mas_bottom).offset(kHeightProportion_In_iPhoneTriploid(5));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(22)));
        }];
        //
        self.inventoryLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(12) theColor:[UIColor colorWithHexString:@"#999999"] inSuperView:bankgroundView];
        self.inventoryLabel.backgroundColor = kRandomColor;
        self.inventoryLabel.text = @"库存36件";
        [self.inventoryLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.specLabel.mas_right).offset(kWidthProportion_In_iPhoneTriploid(10));
            make.top.equalTo(self.stellNameLabel.mas_bottom).offset(kHeightProportion_In_iPhoneTriploid(8));
            make.right.equalTo(bankgroundView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(15));
        }];
        //
        self.warehouseLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(12) theColor:[UIColor colorWithHexString:@"#999999"] inSuperView:bankgroundView];
        self.warehouseLabel.backgroundColor = kRandomColor;
        self.warehouseLabel.text = @"杭州热联合仓库";
        [self.warehouseLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.specLabel);
            make.top.equalTo(self.specLabel.mas_bottom).offset(kHeightProportion_In_iPhoneTriploid(5));
            make.right.equalTo(bankgroundView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(15));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(17)));
        }];
        //
        self.piceLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(14) theColor:[UIColor colorWithHexString:@"#FF374F"] inSuperView:bankgroundView];
        self.piceLabel.text = @"¥3845/吨";
        self.piceLabel.backgroundColor = kRandomColor;
        [self.piceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.warehouseLabel);
            make.top.equalTo(self.warehouseLabel.mas_bottom).offset(kHeightProportion_In_iPhoneTriploid(5));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(20)));
        }];
        //
        showConfBut = [[GLGWButton alloc] initWithTitle:@"显示联系人" titleLableFont:SYSTEMFONT(12) titleLableColor:[UIColor colorWithHexString:@"#999999"] inSuperView:bankgroundView];
        showConfBut.backgroundColor = kRandomColor;
        showConfBut.tag = 125;
        [showConfBut setTitle:@"收起" forState:UIControlStateSelected];
        [showConfBut mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(bankgroundView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(15));
            make.top.equalTo(self.piceLabel.mas_top).offset(kHeightProportion_In_iPhoneTriploid(3));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(20)));
        }];
        [showConfBut addTarget:self action:@selector(showInfor:) forControlEvents:UIControlEventTouchUpInside];
        //
        self.lineView = [[GLGWView alloc] initWithInSuperView:bankgroundView];
        self.lineView.backgroundColor = [UIColor colorWithHexString:@"#EAEAEA"];
        [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(bankgroundView.mas_left).offset(kWidthProportion_In_iPhoneTriploid(15));
            make.top.equalTo(self.leftImageView.mas_bottom).offset(kHeightProportion_In_iPhoneTriploid(13));
            make.right.equalTo(bankgroundView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(15));
            make.height.equalTo(@1);
        }];
        //
        self.contactLabel = [[GLGWLabel alloc] initWithFont:SYSTEMFONT(14) theColor:[UIColor colorWithHexString:@"#999999"] inSuperView:bankgroundView];
        self.contactLabel.attributedText = [GLGWLabel bllChangeStr:@"业务联系人  张海涛" changewithStr:@"张海涛" changeColoer:kColor_Rule_Black withFont:SYSTEMFONT(14)];
        [self.contactLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.lineView);
            make.top.equalTo(self.lineView.mas_bottom).offset(kHeightProportion_In_iPhoneTriploid(12));
        }];
        //
        contactBut = [[GLGWButton alloc] initWithTitle:@"联系卖家" titleLableFont:SYSTEMFONT(12) titleLableColor:[UIColor whiteColor] theCornerRadius:3.0 backgroundColr:kColor_Rule_Yellow inSuperView:bankgroundView];
        [contactBut mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(bankgroundView.mas_right).offset(-kWidthProportion_In_iPhoneTriploid(15));
            make.top.equalTo(self.lineView.mas_bottom).offset(kHeightProportion_In_iPhoneTriploid(9));
            make.width.equalTo(@(kWidthProportion_In_iPhoneTriploid(55)));
            make.height.equalTo(@(kHeightProportion_In_iPhoneTriploid(25)));
        }];
        contactBut.tag = 126;
        [contactBut addTarget:self action:@selector(showInfor:) forControlEvents:UIControlEventTouchUpInside];
    }
    return self;
}
-(void)showInfor:(GLGWButton *)sender{
    if (sender.tag == 125) {
        sender.selected = !sender.selected;
        _lookCellModel.isOpen = sender.selected;
    }
    if (self.Block_CellOpen) {
        self.Block_CellOpen(sender);
    }
}

-(void)setLookCellModel:(LookForGoodsModel *)lookCellModel{
    _lookCellModel = lookCellModel;
    showConfBut.selected = _lookCellModel.isOpen;
    if (_lookCellModel.isOpen) {
        self.contactLabel.hidden = NO;
        self.lineView.hidden = NO;
        contactBut.hidden = NO;
    }else{
        self.contactLabel.hidden = YES;
        self.lineView.hidden = YES;
        contactBut.hidden = YES;
    }
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
